<template>
	<div class="services">
		<el-table :data="pageData.items" style="width: 100%;">
			<el-table-column prop="name" label="开始时间">
				<template slot-scope="scope">
					{{ scope.row.startDate }} <br />
					{{ scope.row.startWeekDay }}
				</template>
			</el-table-column>
			<el-table-column prop="name1" label="结束时间">
				<template slot-scope="scope">
					{{ scope.row.endDate }} <br />
					{{ scope.row.endWeekDay }}
				</template>
			</el-table-column>
			<el-table-column prop="base" label="基地"></el-table-column>
			<el-table-column prop="baseLocation" label="基地位置"></el-table-column>
			<el-table-column prop="name" label="联系人"></el-table-column>
			<el-table-column prop="phone" label="联系号码"></el-table-column>
			<el-table-column prop="content" label="管理内容"></el-table-column>
			<el-table-column prop="remark" label="说明"></el-table-column>
			<el-table-column prop="address" label="操作" width="140">
				<template slot-scope="scope">
					<el-button type="text" size="small" @click="taskAllocation(scope.row)">任务分配</el-button>
					<el-button type="text" size="small" class="isdelate" @click="cancelTheTask(scope.row)">取消任务</el-button>
				</template>
			</el-table-column>
		</el-table>
		<pagina-tion :totalNum="pageData.totalNum" @paginaClick="paginaClick"></pagina-tion>
		<!-- 任务分配 -->
		<!-- <el-dialog title="任务分配" :visible.sync="dialogVisible" width="600px">
			<span>
				<el-form label-width="100px" :model="formLabelAlign">
					<el-form-item label="选择服务队">
						<el-select v-model="formLabelAlign.teamId" placeholder="选择服务队">
							<el-option v-for="item in dialogData.items" :label="item.serviceName" :value="item.id"></el-option>
						</el-select>
					</el-form-item>
				</el-form>
			</span>
			<span slot="footer" class="dialog-footer">
				<el-button @click="dialogVisible = false">取 消</el-button>
				<el-button type="primary" @click="newTaskToTeam">确 定</el-button>
			</span>
		</el-dialog> -->

	</div>
</template>

<script>
	export default {
		data() {
			return {
				companyId: '',
				tableData: [],
				pageData: '',
				queryData: {
					companyId: '',
					page: 1,
					pageSize: $globalData.pageSize
				},
				// 任务分配
				// dialogVisible: false,
				// formLabelAlign: {
				// 	teamId: '',
				// 	serviceId: '',
				// 	equipmentIds: ''
				// },
				// dialogData: ''
			}
		},
		computed: {
			monitor() {
				return this.$store.state.company.companyId
			}
		},
		watch: {
			monitor(newData) {
				this.queryData.companyId = newData
				this.queryData.page = 1
				this.getPageData()
			},
			dialogVisible(newData) {
				if (!newData) {
					this.formLabelAlign.teamId = ''
				}
			}
		},
		mounted() {
			this.companyId = this.queryData.companyId = this.$store.state.company.companyId
			this.getPageData()
		},
		methods: {
			getPageData() {
				this.$request.postForm(this.$api.getNotArrangedTask, this.queryData).then(res => {
					if (res.code == 200) {
						this.pageData = res.data
					}
				})
			},
			paginaClick(val) {
				this.queryData.page = val
				this.getPageData()
			},
			taskAllocation(row) {
				// 分配任务
				this.$router.push(`/industrialist/working/taskallocation/${row.id}`)
				// this.getserviceList()
				// this.dialogVisible = true
				// this.formLabelAlign.serviceId = row.id
			},
			// getserviceList() {
			// 	this.$request.get(this.$api.queryServiceTeamList, {
			// 		companyId: this.companyId,
			// 		page: 1,
			// 		pageSize: 20000
			// 	}).then(res => {
			// 		if (res.code == 200) {
			// 			this.dialogData = res.data
			// 		}
			// 	})
			// },
			// newTaskToTeam() {
			// 	// 分配任务至服务队
			// 	if (!this.formLabelAlign.teamId) {
			// 		this.$message.error('请选择服务队')
			// 		return
			// 	}
			// 	this.$request.postForm(this.$api.newTaskToTeam, this.formLabelAlign).then(res => {
			// 		if (res.code == 200) {
			// 			this.$message.success('任务分配成功')
			// 			this.getPageData()
			// 			this.dialogVisible = false
			// 		}
			// 	})
			// },
			cancelTheTask(row) {
				// 取消当前任务
				this.$confirm('确定要取消当前任务?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					this.$request.postForm(this.$api.removeTaskFromCompany, {
						taskId: row.id,
						companyId: this.companyId
					}).then(res=>{
						if(res.code == 200){
							this.$message({
								type: 'success',
								message: '删除成功!'
							});
							if(this.queryData.page > 1){
								this.queryData.page = Math.ceil((this.pageData.totalNum - 1) / $globalData.pageSize)
							}
							this.getPageData()
						}
					})
				})
			}
		}
	}
</script>

<style scoped="scoped">
	.menberConTitle {
		width: 100%;
		background: #F3F3F3;
		text-align: left;
		padding: 5px 20px;
		margin-bottom: 20px;
		margin-top: 20px;
	}

	.tableTitle {
		font-size: 16px;
		font-family: Microsoft YaHei;
		font-weight: 400;
		color: #333333;
		line-height: 30px;
	}

	.services>>>.isdelate {
		color: #F42929;
	}
</style>
